﻿@{
    Layout = "~/Areas/Web/Views/Shared/_UserCenter.cshtml";
    ViewBag.Title = "店铺关注";
}
@model  IEnumerable<Himall.Web.Areas.Web.Models.ShopConcernModel>

<link href="~/Areas/Web/Content/shop.css" rel="stylesheet" />

<div class="box1 lh24">
    <div class="title bot-border">
        <h3 class="title_txt cur">店铺关注</h3>
    </div>
    <div class="border-box">
        @if (Model.Count() == 0)
        {
            <div class="empty"><b></b>暂时没有关注任何店铺！</div>
        }
        @foreach (var m in Model)
        {
            <div id="tr_@m.FavoriteShopInfo.Id" class="storeinfo">
                <div class="i-store">
                    <div class="i-logo">
                        <input type="checkbox" class="check" name="r" value="@m.FavoriteShopInfo.Id">
                        <label>
                            <!--<a href="@Url.Action("home","shop", new {id=@m.FavoriteShopInfo.ShopId })" target="_blank">
                                <img  data-img="1" class="err-product" src="@m.FavoriteShopInfo.Logo">
                            </a>-->
                            <div class="s-name"><a href="@Url.Action("home","shop", new {id=@m.FavoriteShopInfo.ShopId })" target="_blank"> @m.FavoriteShopInfo.ShopName </a></div>
                        </label>
                    </div>
                    <!-- 标签功能-->
                    <ul class="list-info">
                        <li>关注人气：@m.FavoriteShopInfo.ConcernCount 人</li>
                        <!--<li>
                            @{ var servicemark = @m.FavoriteShopInfo.SericeMark == 0 ? 5 : @m.FavoriteShopInfo.SericeMark; var mark = @Math.Round(servicemark);}
                            服务评价： <span class="grade"><em class="g@{@mark}"></em></span>
                            <span title="@servicemark">@servicemark</span>
                        </li>-->
                        <li>关注时间： @m.FavoriteShopInfo.ConcernTime.ToShortDateString() </li>
                    </ul>
                    <div class="btns">
                        <a class="btn btn-11 id_follow" data="@m.FavoriteShopInfo.Id" href="javascript:;"><s></s>取消关注</a><br /><br />
                        @Html.Action("CustmerServices", new { shopId = @m.FavoriteShopInfo.ShopId })
                    </div>
                </div>
                <div class="i-shop">
                    <div id="sale_@{@m.FavoriteShopInfo.Id}" class="i-st">
                        <ul class="tab">
                            <li class="curr id_tab_btn" data="hot@{@m.FavoriteShopInfo.Id}">本店热卖</li>
                            <li class="id_tab_btn" data="new@{@m.FavoriteShopInfo.Id}">本店新品</li>
                        </ul>
                    </div>
                    <div class="mscon">
                        <!-- 本店热卖-->
                        <div class="mscoll" id="hot@{@m.FavoriteShopInfo.Id}" data="hot_@{@m.FavoriteShopInfo.Id}">
                            <div class="mleft">上一个</div>
                            <div class="mright">下一个</div>
                            <div class="mslist" style="height:220px;width:710px;">
                                <ul class="list-h" style="width:1845px;" id="hot_@m.FavoriteShopInfo.Id">

                                    @foreach (var p in m.HotSaleProducts)
                                    {
                                        <li>
                                            <div class="p-img" style="height:110px;">
                                                <a href="@Url.Action("Detail", "Product", new { id = @p.Id })" title="@p.Name" target="_blank">
                                                    <img width="130" height="130" data-img="1" src="@p.ImgPath/1_100.png" alt="@p.Name">
                                                </a>
                                            </div>
                                            <div class="p-name" style="height:auto">
                                                @{
                                                    var name = p.Name.Length > 10 ? p.Name.Substring(0, 10) +"...": p.Name;
                                                }
                                                <a href="@Url.Action("Detail", "Product", new { id = @p.Id })" title="@p.Name" target="_blank">@name</a>
                                            </div>
                                            <div class="p-price">价格：<strong class="ftx-01">￥@p.Price.ToString("f2")</strong></div>
                                        </li>
                                    }
                                </ul>
                            </div>
                            <div class="clr"></div>
                        </div>
                        <!--本店新品-->
                        <div class="mscoll hide" id="new@{@m.FavoriteShopInfo.Id}" data="new_@{@m.FavoriteShopInfo.Id}">
                            <div class="mleft">上一个</div>
                            <div class="mright">下一个</div>
                            <div class="mslist">
                                <ul class="list-h" id="new_@{@m.FavoriteShopInfo.Id}">
                                    @foreach (var p in m.NewSaleProducts)
                                    {
                                        <li>
                                            <div class="p-img" style="height:110px;">
                                                <a href="@Url.Action("Detail", "Product", new { id = @p.Id })" title="@p.Name" target="_blank">
                                                    <img width="130" height="130" data-img="1" src="@p.ImgPath/1_100.png" alt="@p.Name">
                                                </a>
                                            </div>
                                            <div class="p-name">
                                                @{
                                        var name = p.Name.Length > 10 ? p.Name.Substring(0, 10) + "..." : p.Name;
                                                }
                                                <a href="@Url.Action("Detail", "Product", new { id = @p.Id })" title="@p.Name" target="_blank">@name</a>
                                            </div>
                                            <div class="p-price">价格：<strong class="ftx-01">￥@p.Price.ToString("f2")</strong></div>
                                        </li>
                                    }
                                </ul>
                            </div>
                            <div class="clr"></div>
                        </div>
                    </div>
                </div>
            </div>
        }
		<div class="mb mt10">
			<div class="i-option">
				<input type="checkbox" class="check checkall" value="" name="" id="allCheckbox">
				<label for="allCheckbox">全选</label>
				<a class="id_follow" href="javascript:;">取消关注</a>
			</div>
			<div id="pagin-btm" class="pagin fr">
				@{
					var count = ((PagingInfo)ViewBag.pageInfo).TotalPages;
					var curr = ((PagingInfo)ViewBag.pageInfo).CurrentPage;
				}
				@Html.PageLinks((PagingInfo)ViewBag.pageInfo, x => Url.Action("Index", new { pageNo = x }))
				<span class="page-skip">
					<em>&nbsp;&nbsp;共 @count 页&nbsp;&nbsp;&nbsp;&nbsp;</em>
				</span>
			</div>
		</div>

    </div>
    
</div>
<script>
    (function ($) {
        $('.checkall').change(function () {
            $('.storeinfo').find('input[type=checkbox]').attr('checked', this.checked);

        });
        $('.id_follow').each(function () {
            var obj = $(this),
                bool = obj.attr('data') || 0;
            obj.bind('click', function () {
                if (bool) {
                    //
                    var loading = showLoading();
                    $.ajax({
                        type: 'post',
                        url: "@Url.Action("CancelConcernShops")",
                        data: { ids: bool },
                        dataType: "json",
                        success: function (data) {
                            loading.close();
                            if (data.success)
                                $('#tr_' + bool).remove();
                        }
                    });
                } else {
                    var arr = [], str = '';
                    $("input:checkbox[name='r']:checked").each(function (i, e) {
                        arr.push($(e).val());
                    });
                    str = arr.join(',');
                    var loading = showLoading();
                    $.ajax({
                        type: 'post',
                        url: "@Url.Action("CancelConcernShops")",
                        data: { ids: str },
                        dataType: "json",
                        success: function (data) {
                            loading.close();
                            if (data.success) {
                                for (var i = 0, e; e = arr[i++];) {
                                    $('#tr_' + e).remove();
                                }
                            }
                            arr = [];
                        }
                    });
                }
            });
        });

        $('.id_tab_btn').each(function (i, e) {
            $(e).bind('click', function () {
                var tag = $(this).attr('data');
                $(e).siblings().removeClass('curr');
                $(e).addClass('curr');
                $('#' + tag).siblings().hide();
                $('#' + tag).show();
            });
        });
        var fn = function (elem, pre, next, num, fix) {
            var dom = $(elem),
                a = dom.children().length,// 容器里面有元素的个数用来确定是否滚动和最大滚动次数
                b = Math.ceil(a / 5, 10),// 最大滚动次数
                pre = pre,
                uid = 1,
                next = next;
            if (a >= 5) {
                dom.css({ width: (a * num) + 'px' });
                next.bind('click', function (e) {
                    if (uid < b) {
                        //console.log(uid)
                        dom.animate({ marginLeft: -(fix * uid) }, "slow");
                        uid++;
                    }
                });
                pre.bind('click', function (e) {
                    if (uid > 1) {
                        uid--;
                        dom.animate({ marginLeft: -(fix * (uid - 1)) }, "slow");
                    }
                });
            }
        };
        $('.mscoll').each(function (i, e) {
            var tag = $(e).attr('data');
            $(e).find('.mleft')
            $(e).find('.mright')
            fn('#' + tag, $(e).find('.mleft'), $(e).find('.mright'), 144, 720);
        });
    }(jQuery));
</script>
